/**
 * 树形下拉框
 */
var setting = { 
	view: { 
		dblClickExpand: false 
	}, 
	data: { 
		simpleData: { 
			enable: true 
		} 
	}, 
	callback: { 
		beforeClick: beforeClick, 
		onClick: onClick 
	} 
}; 

function beforeClick(treeId, treeNode) { 
	var check = (treeNode && !treeNode.isParent); 
	return check; 
} 

function onClick(e, treeId, treeNode) { 
	var zTree = $.fn.zTree.getZTreeObj("treeObject"), 
	nodes = zTree.getSelectedNodes(), 
	v = ""; 
	ids = "";
	nodes.sort(function compare(a,b){return a.id-b.id;}); 
	for (var i=0, l=nodes.length; i<l; i++) { 
		v += nodes[i].name + ","; 
		ids += nodes[i].id + ","; 
	} 
	if (v.length > 0 ) v = v.substring(0, v.length-1); 
	if (ids.length > 0 ) ids = ids.substring(0, ids.length-1); 
	var node = $("#treeNode"); 
	var nodevalue = $("#treeValue"); 
	node.attr("value", v); 
	nodevalue.attr("value", ids); 
} 

function showMenu() { 
	var cityObj = $("#treeNode"); 
	var cityOffset = $("#treeNode").offset(); 
	$("#treeObject").css({width:cityObj.outerWidth()});
	$("#menuContent").css({left:"0px", top:cityObj.outerHeight() + "px"}).slideDown("fast");	
	$("body").bind("mousedown", onBodyDown); 
} 
function hideMenu() { 
	$("#menuContent").fadeOut("fast"); 
	$("body").unbind("mousedown", onBodyDown); 
} 
function onBodyDown(event) { 
	if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) { 
		hideMenu(); 
	} 
} 
